<template>
    <div class="default-main ba-table-box">
        <el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info"
            show-icon />

        <!-- 表格顶部菜单 -->
        <TableHeader :buttons="['refresh', 'edit', 'comSearch', 'quickSearch', 'columnDisplay']"
            :quick-search-placeholder="t('quick Search Placeholder', { fields: t('oilOrderRefund.quick Search Fields') })"
            @action="baTable.onTableHeaderAction" />

        <!-- 表格 -->
        <!-- 要使用`el-table`组件原有的属性，直接加在Table标签上即可 -->
        <Table ref="tableRef" @action="baTable.onTableAction" />

        <!-- 表单 -->
        <PopupForm />
    </div>
</template>

<script setup lang="ts">
import { ref, provide, onMounted } from 'vue'
import baTableClass from '/@/utils/baTable'
import { oilOrderRefund } from '/@/api/controllerUrls'
import { defaultOptButtons } from '/@/components/table'
import { baTableApi } from '/@/api/common'
import { useI18n } from 'vue-i18n'
import PopupForm from './popupForm.vue'
import Table from '/@/components/table/index.vue'
import TableHeader from '/@/components/table/header/index.vue'

const { t } = useI18n()
const tableRef = ref()
const optButtons = defaultOptButtons(["edit"])
const baTable = new baTableClass(
    new baTableApi(oilOrderRefund),
    {
        pk: 'id',
        column: [
            { type: 'selection', align: 'center', operator: false },
            { label: t('oilOrderRefund.id'), prop: 'id', align: 'center', width: 70, sortable: 'custom', operator: 'RANGE' },
            { label: '退款订单号', prop: 'refund_sn', align: 'center', operator: 'LIKE', width: 220 },
            { label: t('oilOrderRefund.order_sn'), prop: 'oilOrderInfo.order_sn', align: 'center', operator: 'LIKE', width: 220 },
            { label: t('oilOrderRefund.price'), prop: 'price', align: 'center', operator: 'RANGE' },
            { label: t('oilOrderRefund.images'), prop: 'images', align: 'center', render: 'images', operator: false },
            { label: t('oilOrderRefund.reason'), prop: 'reason', align: 'center', operator: 'LIKE', 'min-width': 180 },
            { label: t('oilOrderRefund.remark'), prop: 'remark', align: 'center', operator: 'LIKE', 'min-width': 180 },
            { label: t('oilOrderRefund.state'), prop: 'state', align: 'center', render: 'tag', replaceValue: { 0: t('oilOrderRefund.state 0'), 1: t('oilOrderRefund.state 1'), 2: t('oilOrderRefund.state 2'), 3: t('oilOrderRefund.state 3') } },
            { label: t('oilOrderRefund.createtime'), prop: 'createtime', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            { label: t('oilOrderRefund.updatetime'), prop: 'updatetime', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
            { label: t('operate'), align: 'center', width: 100, render: 'buttons', buttons: optButtons, operator: false },
        ],
        dblClickNotEditColumn: [undefined,],
        defaultOrder: { prop: 'id', order: 'desc' },
    },
    {
        defaultItems: { "price": "0.00", "state": "0" },
    }
)

provide('baTable', baTable)

onMounted(() => {
    baTable.table.ref = tableRef.value
    baTable.mount()
    baTable.getIndex()?.then(() => {
        baTable.initSort()
        baTable.dragSort()
    })
})
</script>

<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
    name: 'oilOrderRefund',
})
</script>

<style scoped lang="scss">

</style>
